﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

namespace CGShaderIntegration
{
    class HesseSebastianEarth
    {
        private Model earth;   
        private TextureCube earthTexture;    
        private Effect earthEffect;

        public HesseSebastianEarth(ContentManager Content)
        {
            earth = Content.Load<Model>("models\\HesseSebastianErde");
            earthTexture = Content.Load<TextureCube>("textures\\HesseSebastianEarthCubeMap");
            earthEffect = Content.Load<Effect>("effects\\HesseSebastianEarthEffect");    
            //earthEffect = earth.Meshes[0].Effects[0];
        }

        public void Draw(Matrix world, Matrix view, Matrix projection)
        {
            foreach (ModelMesh mesh in earth.Meshes)
            {               
                 foreach (ModelMeshPart part in mesh.MeshParts)
                 {
                        part.Effect = earthEffect;
                        for (int x = 0; x < part.Effect.Parameters.Count; x++)
                        {
                            //Console.WriteLine(part.Effect.Parameters.ElementAt(x).Name);
                        }
                        part.Effect.Parameters["World"].SetValue(world);
                        part.Effect.Parameters["View"].SetValue(view);
                        part.Effect.Parameters["Projection"].SetValue(projection);
                        part.Effect.Parameters["earthTexture"].SetValue(earthTexture);                
                }
                mesh.Draw();           
            }
        }
    }
}
